import React, { Component } from 'react'
import Search from './Search'
import Users from './Users'

export default class App extends Component {
  state = {
    users: [], // users初始值
    isFirst: true, // 是否是第一次打开页面
    isLoading: false, // 标识是否属于加载中
    err: '' //请求失败的消息
  }

  // 将搜索结果保存到users数组中
  // saveUsers = (users) => {
  //   this.setState({ users })
  // }

  // 更新App的state
  updateAppState = (stateObj) => {

    this.setState(stateObj)
  }
  render() {
    return (
      <div className="container">
        <Search updateAppState={this.updateAppState} />
        <Users {...this.state} />
      </div>
    )
  }
}
